<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: Sass::Plugin</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">Sass::Plugin</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../files/vendor/plugins/haml/lib/sass/plugin_rb.html">
                vendor/plugins/haml/lib/sass/plugin.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
This module contains methods that <a
href="../ActionController.html">ActionController</a> calls to automatically
update <a href="../Sass.html">Sass</a> templates that need updating. It
wasn&#8216;t designed to be used outside of the context of <a
href="../ActionController.html">ActionController</a>.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000052">options</a>&nbsp;&nbsp;
      <a href="#M000053">options=</a>&nbsp;&nbsp;
      <a href="#M000054">update_stylesheets</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000052" class="method-detail">
        <a name="M000052"></a>

        <div class="method-heading">
          <a href="#M000052" class="method-signature">
          <span class="method-name">options</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Gets various <a href="Plugin.html#M000052">options</a> for <a
href="../Sass.html">Sass</a>. See README for details.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000052-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000052-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/haml/lib/sass/plugin.rb, line 25</span>
25:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">options</span>
26:         <span class="ruby-ivar">@@options</span>
27:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000053" class="method-detail">
        <a name="M000053"></a>

        <div class="method-heading">
          <a href="#M000053" class="method-signature">
          <span class="method-name">options=</span><span class="method-args">(value)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Sets various <a href="Plugin.html#M000052">options</a> for <a
href="../Sass.html">Sass</a>.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000053-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000053-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/haml/lib/sass/plugin.rb, line 30</span>
30:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">options=</span>(<span class="ruby-identifier">value</span>)
31:         <span class="ruby-ivar">@@options</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">value</span>)
32:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000054" class="method-detail">
        <a name="M000054"></a>

        <div class="method-heading">
          <a href="#M000054" class="method-signature">
          <span class="method-name">update_stylesheets</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Checks each stylesheet in <tt><a
href="Plugin.html#M000052">options</a>[:css_location]</tt> to see if it
needs updating, and updates it using the corresponding template from <tt><a
href="Plugin.html#M000052">options</a>[:templates]</tt> if it does.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000054-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000054-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/haml/lib/sass/plugin.rb, line 39</span>
39:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">update_stylesheets</span>
40:         <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:template_location</span>], <span class="ruby-value str">&quot;**&quot;</span>, <span class="ruby-value str">&quot;*.sass&quot;</span>)).<span class="ruby-identifier">entries</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
41:           
42:           <span class="ruby-comment cmt"># Get the relative path to the file with no extension</span>
43:           <span class="ruby-identifier">name</span> = <span class="ruby-identifier">file</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:template_location</span>] <span class="ruby-operator">+</span> <span class="ruby-value str">&quot;/&quot;</span>, <span class="ruby-value str">&quot;&quot;</span>)[<span class="ruby-value">0</span><span class="ruby-operator">...</span><span class="ruby-value">-5</span>]
44:                     
45:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:always_update</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">stylesheet_needs_update?</span>(<span class="ruby-identifier">name</span>)
46:             <span class="ruby-identifier">css</span> = <span class="ruby-identifier">css_filename</span>(<span class="ruby-identifier">name</span>)
47:             <span class="ruby-constant">File</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">css</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">css</span>)
48:             
49:             <span class="ruby-identifier">filename</span> = <span class="ruby-identifier">template_filename</span>(<span class="ruby-identifier">name</span>)
50:             <span class="ruby-identifier">l_options</span> = <span class="ruby-ivar">@@options</span>.<span class="ruby-identifier">dup</span>
51:             <span class="ruby-identifier">l_options</span>[<span class="ruby-identifier">:filename</span>] = <span class="ruby-identifier">filename</span>
52:             <span class="ruby-identifier">l_options</span>[<span class="ruby-identifier">:load_paths</span>] = (<span class="ruby-identifier">l_options</span>[<span class="ruby-identifier">:load_paths</span>] <span class="ruby-operator">||</span> []) <span class="ruby-operator">+</span> [<span class="ruby-identifier">l_options</span>[<span class="ruby-identifier">:template_location</span>]]
53:             <span class="ruby-identifier">engine</span> = <span class="ruby-constant">Engine</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">filename</span>), <span class="ruby-identifier">l_options</span>)
54:             <span class="ruby-keyword kw">begin</span>
55:               <span class="ruby-identifier">result</span> = <span class="ruby-identifier">engine</span>.<span class="ruby-identifier">render</span>
56:             <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
57:               <span class="ruby-keyword kw">if</span> <span class="ruby-constant">RAILS_ENV</span> <span class="ruby-operator">!=</span> <span class="ruby-value str">&quot;production&quot;</span>
58:                 <span class="ruby-identifier">e_string</span> = <span class="ruby-node">&quot;#{e.class}: #{e.message}&quot;</span>
59: 
60:                 <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Sass</span><span class="ruby-operator">::</span><span class="ruby-constant">SyntaxError</span>
61:                   <span class="ruby-identifier">e_string</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;\non line #{e.sass_line}&quot;</span>
62: 
63:                   <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">sass_filename</span>
64:                     <span class="ruby-identifier">e_string</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; of #{e.sass_filename}&quot;</span>
65: 
66:                     <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">e</span>.<span class="ruby-identifier">sass_filename</span>)
67:                       <span class="ruby-identifier">e_string</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;\n\n&quot;</span>
68: 
69:                       <span class="ruby-identifier">min</span> = [<span class="ruby-identifier">e</span>.<span class="ruby-identifier">sass_line</span> <span class="ruby-operator">-</span> <span class="ruby-value">5</span>, <span class="ruby-value">0</span>].<span class="ruby-identifier">max</span>
70:                       <span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">e</span>.<span class="ruby-identifier">sass_filename</span>).<span class="ruby-identifier">rstrip</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot;\n&quot;</span>)[
71:                           <span class="ruby-identifier">min</span> <span class="ruby-operator">..</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">sass_line</span> <span class="ruby-operator">+</span> <span class="ruby-value">5</span>
72:                       ].<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span>, <span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
73:                         <span class="ruby-identifier">e_string</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;#{min + i + 1}: #{line}\n&quot;</span>
74:                       <span class="ruby-keyword kw">end</span>
75:                     <span class="ruby-keyword kw">end</span>
76:                   <span class="ruby-keyword kw">end</span>
77:                 <span class="ruby-keyword kw">end</span>
78:                 <span class="ruby-identifier">result</span> = <span class="ruby-node">&quot;/*\n#{e_string}\n\nBacktrace:\n#{e.backtrace.join(&quot;\n&quot;)}\n*/&quot;</span>
79:               <span class="ruby-keyword kw">else</span>
80:                 <span class="ruby-identifier">result</span> = <span class="ruby-value str">&quot;/* Internal stylesheet error */&quot;</span>
81:               <span class="ruby-keyword kw">end</span>
82:             <span class="ruby-keyword kw">end</span>
83:             
84:             <span class="ruby-comment cmt"># Create any directories that might be necessary</span>
85:             <span class="ruby-identifier">dirs</span> = [<span class="ruby-identifier">l_options</span>[<span class="ruby-identifier">:css_location</span>]]
86:             <span class="ruby-identifier">name</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot;/&quot;</span>)[<span class="ruby-value">0</span><span class="ruby-operator">...</span><span class="ruby-value">-1</span>].<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span> <span class="ruby-identifier">dirs</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;#{dirs[-1]}/#{dir}&quot;</span> }
87:             <span class="ruby-identifier">dirs</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span> <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-identifier">dir</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">dir</span>) }
88:             
89:             <span class="ruby-comment cmt"># Finally, write the file</span>
90:             <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">css</span>, <span class="ruby-value str">'w'</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
91:               <span class="ruby-identifier">file</span>.<span class="ruby-identifier">print</span>(<span class="ruby-identifier">result</span>)
92:             <span class="ruby-keyword kw">end</span>
93:           <span class="ruby-keyword kw">end</span>
94:         <span class="ruby-keyword kw">end</span>
95:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>